<template>
  <div class="app-container">
    <el-button type="primary" style="margin-bottom: 20px" @click="handleInsert">新增成果类型</el-button>
    <el-dialog
      :title="form.title"
      :visible.sync="dialogFormVisible"
      width="30%"
    >
      <el-form :model="form">
        <el-form-item label="加/减分项" :label-width="formLabelWidth">
          <el-radio-group v-model="form.as_positive_award" :disabled="form.up_type === 'Update'">
            <el-radio label="加分项" />
            <el-radio label="减分项" />
          </el-radio-group>
        </el-form-item>
        <el-form-item label="评分方面" :label-width="formLabelWidth">
          <el-autocomplete
            v-model="form.as_scoring_aspect"
            class="inline-input"
            :fetch-suggestions="querySearchScoringAspect"
            placeholder="请输入内容"
            :disabled="form.up_type === 'Update'"
            @select="handleSelect"
          />
        </el-form-item>
        <el-form-item label="评分单项" :label-width="formLabelWidth">
          <el-autocomplete
            v-model="form.as_scoring_item"
            class="inline-input"
            :fetch-suggestions="querySearchScoringItem"
            placeholder="请输入内容"
            :disabled="form.up_type === 'Update'"
            @select="handleSelect"
          />
        </el-form-item>
        <el-form-item label="评分点" :label-width="formLabelWidth">
          <el-autocomplete
            v-model="form.as_award_level"
            class="inline-input"
            :fetch-suggestions="querySearchAwardLevel"
            placeholder="请输入内容"
            :disabled="form.up_type === 'Update'"
            @select="handleSelect"
          />
        </el-form-item>
        <el-form-item v-if="form.up_type==='Insert'" label="成果属性" :label-width="formLabelWidth">
          <el-select
            v-model="form.attributes"
            multiple
            filterable
            allow-create
            default-first-option
            placeholder="请填入成果属性"
          >
            <el-option
              v-for="item in form.attributesOptions"
              :key="item.value"
              :label="item.label"
              :value="item.value"
            />
          </el-select>
        </el-form-item>
        <el-form-item label="评价方面权重" :label-width="formLabelWidth">
          <el-input-number v-model="form.as_aspect_weight" :precision="2" :step="1" :max="100" size="small" />
        </el-form-item>
        <el-form-item label="评分单项权重" :label-width="formLabelWidth">
          <el-input-number v-model="form.as_item_weight" :precision="2" :step="1" :max="100" size="small" />
        </el-form-item>
        <el-form-item label="该小项的权重" :label-width="formLabelWidth">
          <el-input-number v-model="form.as_level_weight" :precision="2" :step="1" :max="100" size="small" />
        </el-form-item>
        <el-form-item label="该小项的分值" :label-width="formLabelWidth">
          <el-input-number v-model="form.as_level_value" :precision="2" :step="1" :max="100" size="small" />
        </el-form-item>
        <el-form-item label="是否归一化" :label-width="formLabelWidth">
          <el-switch v-model="form.is_normalized" />
        </el-form-item>
        <el-form-item label="是否激活" :label-width="formLabelWidth">
          <el-switch v-model="form.as_state" />
        </el-form-item>
      </el-form>
      <div slot="footer" class="dialog-footer">
        <el-button @click="dialogFormVisible = false">取 消</el-button>
        <el-button type="primary" @click="handleFormClick">{{ form.up_type === 'Insert' ? '下一步' : '确 认' }}</el-button>
      </div>
    </el-dialog>
    <el-dialog
      title="提示"
      :visible.sync="dialogVisible"
      width="30%"
    >
      <span>是否确定删除该成果类型</span>
      <span slot="footer" class="dialog-footer">
        <el-button type="primary" @click="awardDelete">确 定</el-button>
        <el-button @click="dialogVisible = false">取 消</el-button>
      </span>
    </el-dialog>
    <el-dialog
      title="提示"
      :visible.sync="dialogAttributeForm.deleteAttributeVisible"
      width="30%"
    >
      <span>是否确定删除该成果属性</span>
      <span slot="footer" class="dialog-footer">
        <el-button type="primary" @click="deleteAttribute">确 定</el-button>
        <el-button @click="dialogAttributeForm.deleteAttributeVisible = false">取 消</el-button>
      </span>
    </el-dialog>
    <el-dialog
      title="编辑成果属性"
      :visible.sync="dialogAttributeForm.Visible"
      width="50%"
    >
      <el-dialog
        title="提示"
        :visible.sync="dialogAttributeForm.deleteAttributeLimitVisible"
        width="30%"
        center
        append-to-body
      >
        <span>是否确定删除该限制条件</span>
        <span slot="footer" class="dialog-footer">
          <el-button type="primary" @click="deleteAttributeLimit">确 定</el-button>
          <el-button @click="dialogAttributeForm.deleteAttributeLimitVisible = false">取 消</el-button>
        </span>
      </el-dialog>
      <el-dialog
        title="提示"
        :visible.sync="dialogAttributeForm.changeAttributeTypeVisible"
        width="25%"
        center
        append-to-body
      >
        <span>如果更改输入框类型，会删除所有限制</span>
        <span slot="footer" class="dialog-footer">
          <el-button type="primary" @click="changeAttributeType">确 定</el-button>
          <el-button @click="dialogAttributeForm.changeAttributeTypeVisible = false">取 消</el-button>
        </span>
      </el-dialog>
      <el-dialog
        title="新增成果属性"
        :visible.sync="dialogAttributeForm.insertAttributeVisible"
        width="30%"
        center
        append-to-body
      >
        <div style="text-align:center">
          <span>请输入想要添加的成果属性</span>
        </div>
        <br>
        <el-form :model="dialogAttributeForm.insertAttributeForm">
          <el-form-item label="成果属性" :label-width="formLabelWidth">
            <el-select
              v-model="dialogAttributeForm.insertAttributeForm.attributeNames"
              multiple
              filterable
              allow-create
              default-first-option
              placeholder="请填入想添加的成果属性"
            >
              <el-option
                v-for="item in form.attributesOptions"
                :key="item.value"
                :label="item.label"
                :value="item.value"
              />
            </el-select>
          </el-form-item>
        </el-form>
        <span slot="footer" class="dialog-footer">
          <el-button type="primary" @click="insertAttribute">确 定</el-button>
          <el-button @click="dialogAttributeForm.insertAttributeVisible = false">取 消</el-button>
        </span>
      </el-dialog>
      <el-dialog
        title="新增选择范围"
        :visible.sync="dialogAttributeForm.addChoicesVisible"
        width="30%"
        center
        append-to-body
      >
        <br>
        <br>
        <el-select
          v-model="dialogAttributeForm.addChoiceForm.choices"
          multiple
          filterable
          allow-create
          default-first-option
          placeholder="请输入要添加的选项"
        />
        <span slot="footer" class="dialog-footer">
          <el-button type="primary" @click="addChoices">确 定</el-button>
          <el-button @click="dialogAttributeForm.addChoicesVisible = false">取 消</el-button>
        </span>
      </el-dialog>
      <el-dialog
        title="修改该限制取值"
        :visible.sync="dialogAttributeForm.updateAttributeLimitVisible"
        width="30%"
        center
        append-to-body
      >
        <br>
        <br>
        <el-input
          v-if="dialogAttributeForm.selectedLimit.lavOperation !== '类型'"
          v-model="dialogAttributeForm.selectedLimit.lavValue"
        />
        <el-select
          v-if="dialogAttributeForm.selectedLimit.lavOperation === '类型'"
          v-model="dialogAttributeForm.selectedLimit.lavValue"
        >
          <el-option label="单选" value="单选" />
          <el-option label="多选" value="多选" />
          <el-option label="纯文本" value="纯文本" />
          <el-option label="数字" value="数字" />
          <el-option label="附件" value="附件" />
        </el-select>

        <el-button
          v-if="dialogAttributeForm.selectedLimit.lavOperation === '选择范围'"
          type="primary"
          plain
          :disabled="dialogAttributeForm.selectedLimit.lavValue === ''"
          @click="handleAddChoicesInChange"
        >添加选项
        </el-button>

        <span slot="footer" class="dialog-footer">
          <el-button
            v-if="dialogAttributeForm.selectedLimit.lavOperation !== '类型'"
            type="primary"
            @click="updateAttributeLimit"
          >确 定</el-button>
          <el-button
            v-if="dialogAttributeForm.selectedLimit.lavOperation === '类型'"
            type="primary"
            @click="dialogAttributeForm.changeAttributeTypeVisible = true"
          >确 定</el-button>
          <el-button @click="dialogAttributeForm.updateAttributeLimitVisible = false">取 消</el-button>
        </span>
      </el-dialog>
      <el-dialog
        title="新增限制条件"
        :visible.sync="dialogAttributeForm.addAttributeLimitVisible"
        width="30%"
        center
        append-to-body
      >
        <el-form :model="dialogAttributeForm.selectedAttributes.newLimitForm">
          <el-form-item label="属性类型" :label-width="formLabelWidth">
            <el-select
              v-model="dialogAttributeForm.selectedAttributes.aaAttributeIndex"
              placeholder="请选择"
              :disabled="true"
            >
              <el-option label="名称" value="name" />
              <el-option label="开始时间" value="start_time" />
              <el-option label="结束时间/成果获取时间" value="time" />
              <el-option label="附件信息" value="annex" />
              <el-option label="其他" value="other" />
            </el-select>
          </el-form-item>
          <el-form-item label="输入框类型" :label-width="formLabelWidth">
            <el-select
              v-model="dialogAttributeForm.selectedAttributes.newLimitForm.inputType"
              placeholder="请选择"
              :disabled="dialogAttributeForm.selectedAttributes.newLimitForm.inputTypeIs"
            >
              <el-option label="单选" value="单选" />
              <el-option label="多选" value="多选" />
              <el-option label="纯文本" value="纯文本" />
              <el-option label="数字" value="数字" />
              <el-option label="附件" value="附件" />
            </el-select>
          </el-form-item>
          <el-form-item
            v-show="dialogAttributeForm.selectedAttributes.newLimitForm.inputType==='多选'"
            label="选择范围"
            :label-width="formLabelWidth"
          >
            <el-input
              v-model="dialogAttributeForm.selectedAttributes.newLimitForm.multiSelectWidth"
              :disabled="dialogAttributeForm.selectedAttributes.newLimitForm.multiSelectWidthIs"
            />
            <el-button
              type="primary"
              plain
              :disabled="dialogAttributeForm.selectedAttributes.newLimitForm.multiSelectWidth === '' || dialogAttributeForm.selectedAttributes.newLimitForm.multiSelectWidthIs"
              @click="handleAddChoicesInInsert(dialogAttributeForm.selectedAttributes)"
            >添加选项
            </el-button>
          </el-form-item>
          <el-form-item
            v-show="dialogAttributeForm.selectedAttributes.newLimitForm.inputType==='单选'"
            label="选择范围"
            :label-width="formLabelWidth"
          >
            <el-input
              v-model="dialogAttributeForm.selectedAttributes.newLimitForm.singleSelectWidth"
              :disabled="dialogAttributeForm.selectedAttributes.newLimitForm.singleSelectWidthIs"
            />
            <el-button
              type="primary"
              plain
              :disabled="dialogAttributeForm.selectedAttributes.newLimitForm.singleSelectWidth === '' || dialogAttributeForm.selectedAttributes.newLimitForm.singleSelectWidthIs"
              @click="handleAddChoicesInInsert(dialogAttributeForm.selectedAttributes)"
            >添加选项
            </el-button>
          </el-form-item>
          <el-form-item
            v-show="dialogAttributeForm.selectedAttributes.newLimitForm.inputType==='数字'"
            label="数字类型"
            :label-width="formLabelWidth"
          >
            <el-select
              v-model="dialogAttributeForm.selectedAttributes.newLimitForm.valueType"
              placeholder="请选择"
              :disabled="dialogAttributeForm.selectedAttributes.newLimitForm.valueTypeIs"
            >
              <el-option label="整数" value="整数" />
              <el-option label="小数" value="小数" />
            </el-select>
          </el-form-item>
          <el-form-item
            v-show="dialogAttributeForm.selectedAttributes.newLimitForm.inputType==='数字'"
            label="数字小于"
            :label-width="formLabelWidth"
          >
            <el-input
              v-model="dialogAttributeForm.selectedAttributes.newLimitForm.valueLow"
              :disabled="dialogAttributeForm.selectedAttributes.newLimitForm.valueLowIs"
            />
          </el-form-item>
          <el-form-item
            v-show="dialogAttributeForm.selectedAttributes.newLimitForm.inputType==='数字'"
            label="数字等于"
            :label-width="formLabelWidth"
          >
            <el-input
              v-model="dialogAttributeForm.selectedAttributes.newLimitForm.valueEqual"
              :disabled="dialogAttributeForm.selectedAttributes.newLimitForm.valueEqualIs"
            />
          </el-form-item>
          <el-form-item
            v-show="dialogAttributeForm.selectedAttributes.newLimitForm.inputType==='数字'"
            label="数字大于"
            :label-width="formLabelWidth"
          >
            <el-input
              v-model="dialogAttributeForm.selectedAttributes.newLimitForm.valueHigh"
              :disabled="dialogAttributeForm.selectedAttributes.newLimitForm.valueHighIs"
            />
          </el-form-item>
          <el-form-item
            v-show="dialogAttributeForm.selectedAttributes.newLimitForm.inputType==='数字'&&dialogAttributeForm.selectedAttributes.newLimitForm.valueType==='小数'"
            label="小数的位数"
            :label-width="formLabelWidth"
          >
            <el-input
              v-model="dialogAttributeForm.selectedAttributes.newLimitForm.floatLength"
              :disabled="dialogAttributeForm.selectedAttributes.newLimitForm.floatLengthIs"
            />
          </el-form-item>
          <el-form-item
            v-show="dialogAttributeForm.selectedAttributes.newLimitForm.inputType==='数字'"
            label="数字长度小于"
            :label-width="formLabelWidth"
          >
            <el-input
              v-model="dialogAttributeForm.selectedAttributes.newLimitForm.lengthLow"
              :disabled="dialogAttributeForm.selectedAttributes.newLimitForm.lengthLowIs"
            />
          </el-form-item>
          <el-form-item
            v-show="dialogAttributeForm.selectedAttributes.newLimitForm.inputType==='数字'"
            label="数字长度等于"
            :label-width="formLabelWidth"
          >
            <el-input
              v-model="dialogAttributeForm.selectedAttributes.newLimitForm.lengthEqual"
              :disabled="dialogAttributeForm.selectedAttributes.newLimitForm.lengthEqualIs"
            />
          </el-form-item>
          <el-form-item
            v-show="dialogAttributeForm.selectedAttributes.newLimitForm.inputType==='数字'"
            label="数字长度大于"
            :label-width="formLabelWidth"
          >
            <el-input
              v-model="dialogAttributeForm.selectedAttributes.newLimitForm.lengthHigh"
              :disabled="dialogAttributeForm.selectedAttributes.newLimitForm.lengthHighIs"
            />
          </el-form-item>
          <el-form-item
            v-show="dialogAttributeForm.selectedAttributes.newLimitForm.inputType==='纯文本'"
            label="字符串长度小于"
            :label-width="formLabelWidth"
          >
            <el-input
              v-model="dialogAttributeForm.selectedAttributes.newLimitForm.stringLengthLow"
              :disabled="dialogAttributeForm.selectedAttributes.newLimitForm.stringLengthLowIs"
            />
          </el-form-item>
          <el-form-item
            v-show="dialogAttributeForm.selectedAttributes.newLimitForm.inputType==='纯文本'"
            label="字符串长度等于"
            :label-width="formLabelWidth"
          >
            <el-input
              v-model="dialogAttributeForm.selectedAttributes.newLimitForm.stringLengthEqual"
              :disabled="dialogAttributeForm.selectedAttributes.newLimitForm.stringLengthEqualIs"
            />
          </el-form-item>
          <el-form-item
            v-show="dialogAttributeForm.selectedAttributes.newLimitForm.inputType==='纯文本'"
            label="字符串长度大于"
            :label-width="formLabelWidth"
          >
            <el-input
              v-model="dialogAttributeForm.selectedAttributes.newLimitForm.stringLengthHigh"
              :disabled="dialogAttributeForm.selectedAttributes.newLimitForm.stringLengthHighIs"
            />
          </el-form-item>
        </el-form>
        <span slot="footer" class="dialog-footer">
          <el-button type="primary" @click="updateAttributeLimits">确 定</el-button>
          <el-button @click="dialogAttributeForm.addAttributeLimitVisible = false">取 消</el-button>
        </span>
      </el-dialog>
      <!--
      <el-dialog
        title="新增成果属性"
        :visible.sync="dialogAttributeForm.insertAttributeVisible"
        width="50%"
        center
        append-to-body>
        <el-form :model="dialogAttributeForm.attributes[for_index].newLimitForm">
          <el-form-item label="属性类型" :label-width="formLabelWidth">
            <el-select v-model="dialogAttributeForm.attributes[for_index].aaAttributeIndex" placeholder="请选择">
              <el-option label="名称" value="name"/>
              <el-option label="开始时间" value="start_time"/>
              <el-option label="结束时间/成果获取时间" value="time"/>
              <el-option label="附件信息" value="annex"/>
              <el-option label="其他" value="other"/>
            </el-select>
          </el-form-item>
          <el-form-item label="输入框类型" :label-width="formLabelWidth">
            <el-select v-model="dialogAttributeForm.attributes[for_index].newLimitForm.inputType" placeholder="请选择">
              <el-option label="单选" value="单选"/>
              <el-option label="多选" value="多选"/>
              <el-option label="纯文本" value="纯文本"/>
              <el-option label="数字" value="数字"/>
              <el-option label="附件" value="附件"/>
            </el-select>
          </el-form-item>
          <el-form-item
            v-show="dialogAttributeForm.attributes[for_index].newLimitForm.inputType==='多选'"
            label="选择范围"
            :label-width="formLabelWidth"
          >
            <el-input v-model="dialogAttributeForm.attributes[for_index].newLimitForm.multiSelectWidth"/>

          </el-form-item>
          <el-form-item
            v-show="dialogAttributeForm.attributes[for_index].newLimitForm.inputType==='单选'"
            label="选择范围"
            :label-width="formLabelWidth"
          >
            <el-input v-model="dialogAttributeForm.attributes[for_index].newLimitForm.singleSelectWidth"/>
          </el-form-item>
          <el-form-item
            v-show="dialogAttributeForm.attributes[for_index].newLimitForm.inputType==='数字'"
            label="数字类型"
            :label-width="formLabelWidth"
          >
            <el-select v-model="dialogAttributeForm.attributes[for_index].newLimitForm.valueType" placeholder="请选择">
              <el-option label="整数" value="整数"/>
              <el-option label="小数" value="小数"/>
            </el-select>
          </el-form-item>
          <el-form-item
            v-show="dialogAttributeForm.attributes[for_index].newLimitForm.inputType==='数字'"
            label="数字小于"
            :label-width="formLabelWidth"
          >
            <el-input v-model="dialogAttributeForm.attributes[for_index].newLimitForm.valueLow"/>
          </el-form-item>
          <el-form-item
            v-show="dialogAttributeForm.attributes[for_index].newLimitForm.inputType==='数字'"
            label="数字等于"
            :label-width="formLabelWidth"
          >
            <el-input v-model="dialogAttributeForm.attributes[for_index].newLimitForm.valueEqual"/>
          </el-form-item>
          <el-form-item
            v-show="dialogAttributeForm.attributes[for_index].newLimitForm.inputType==='数字'"
            label="数字大于"
            :label-width="formLabelWidth"
          >
            <el-input v-model="dialogAttributeForm.attributes[for_index].newLimitForm.valueHigh"/>
          </el-form-item>
          <el-form-item
            v-show="dialogAttributeForm.attributes[for_index].newLimitForm.inputType==='数字'&&dialogAttributeForm.attributes[for_index].newLimitForm.valueType==='小数'"
            label="小数的位数"
            :label-width="formLabelWidth"
          >
            <el-input v-model="dialogAttributeForm.attributes[for_index].newLimitForm.floatLength"/>
          </el-form-item>
          <el-form-item
            v-show="dialogAttributeForm.attributes[for_index].newLimitForm.inputType==='数字'"
            label="数字长度小于"
            :label-width="formLabelWidth"
          >
            <el-input v-model="dialogAttributeForm.attributes[for_index].newLimitForm.lengthLow"/>
          </el-form-item>
          <el-form-item
            v-show="dialogAttributeForm.attributes[for_index].newLimitForm.inputType==='数字'"
            label="数字长度等于"
            :label-width="formLabelWidth"
          >
            <el-input v-model="dialogAttributeForm.attributes[for_index].newLimitForm.lengthEqual"/>
          </el-form-item>
          <el-form-item
            v-show="dialogAttributeForm.attributes[for_index].newLimitForm.inputType==='数字'"
            label="数字长度大于"
            :label-width="formLabelWidth"
          >
            <el-input v-model="dialogAttributeForm.attributes[for_index].newLimitForm.lengthHigh"/>
          </el-form-item>
          <el-form-item
            v-show="dialogAttributeForm.attributes[for_index].newLimitForm.inputType==='纯文本'"
            label="字符串长度小于"
            :label-width="formLabelWidth"
          >
            <el-input v-model="dialogAttributeForm.attributes[for_index].newLimitForm.stringLengthLow"/>
          </el-form-item>
          <el-form-item
            v-show="dialogAttributeForm.attributes[for_index].newLimitForm.inputType==='纯文本'"
            label="字符串长度等于"
            :label-width="formLabelWidth"
          >
            <el-input v-model="dialogAttributeForm.attributes[for_index].newLimitForm.stringLengthEqual"/>
          </el-form-item>
          <el-form-item
            v-show="dialogAttributeForm.attributes[for_index].newLimitForm.inputType==='纯文本'"
            label="字符串长度大于"
            :label-width="formLabelWidth"
          >
            <el-input v-model="dialogAttributeForm.attributes[for_index].newLimitForm.stringLengthHigh"/>
          </el-form-item>
        </el-form>
      </el-dialog>
      -->
      <el-button type="primary" style="margin-bottom: 20px" @click="handleAttributeInsert">新增成果属性</el-button>
      <div v-loading="dialogAttributeForm.loading">
        <div
          v-for="(item, for_index) in dialogAttributeForm.attributes"
          :key="item.aaAttribute"
          :span="24"
          class="AttributeItem"
        >
          <el-row style="width: 100%;">
            <el-col :span="12" style="color: black">
              <span>{{ item.aaAttribute }}</span>
            </el-col>
            <el-col :span="12">
              <el-button
                type="danger"
                icon="el-icon-delete"
                size="mini"
                @click="handleAttributeDelete(item)"
              >删除该成果属性
              </el-button>
              <el-button
                v-if="dialogAttributeForm.type === 'view'"
                type="primary"
                icon="el-icon-plus"
                size="mini"
                @click="handleAttributeLimitInsert(for_index)"
              >新增限制条件
              </el-button>
            </el-col>
          </el-row>
          <el-row v-if="dialogAttributeForm.type === 'insert'">
            <el-form :model="dialogAttributeForm.attributes[for_index].newLimitForm">
              <el-form-item label="属性类型" :label-width="formLabelWidth">
                <el-select v-model="dialogAttributeForm.attributes[for_index].aaAttributeIndex" placeholder="请选择">
                  <el-option label="名称" value="name" />
                  <el-option label="开始时间" value="start_time" />
                  <el-option label="结束时间/成果获取时间" value="time" />
                  <el-option label="附件信息" value="annex" />
                  <el-option label="其他" value="other" />
                </el-select>
              </el-form-item>
              <el-form-item label="输入框类型" :label-width="formLabelWidth">
                <el-select v-model="dialogAttributeForm.attributes[for_index].newLimitForm.inputType" placeholder="请选择">
                  <el-option label="单选" value="单选" />
                  <el-option label="多选" value="多选" />
                  <el-option label="纯文本" value="纯文本" />
                  <el-option label="数字" value="数字" />
                  <el-option label="附件" value="附件" />
                </el-select>
              </el-form-item>
              <el-form-item
                v-show="dialogAttributeForm.attributes[for_index].newLimitForm.inputType==='多选'"
                label="选择范围"
                :label-width="formLabelWidth"
              >
                <el-input v-model="dialogAttributeForm.attributes[for_index].newLimitForm.multiSelectWidth" />
                <el-button
                  type="primary"
                  plain
                  :disabled="dialogAttributeForm.attributes[for_index].newLimitForm.multiSelectWidth === ''"
                  @click="handleAddChoicesInInsert(dialogAttributeForm.attributes[for_index])"
                >添加选项
                </el-button>
              </el-form-item>
              <el-form-item
                v-show="dialogAttributeForm.attributes[for_index].newLimitForm.inputType==='单选'"
                label="选择范围"
                :label-width="formLabelWidth"
              >
                <el-input v-model="dialogAttributeForm.attributes[for_index].newLimitForm.singleSelectWidth" />
                <el-button
                  type="primary"
                  plain
                  :disabled="dialogAttributeForm.attributes[for_index].newLimitForm.singleSelectWidth === ''"
                  @click="handleAddChoicesInInsert(dialogAttributeForm.attributes[for_index])"
                >添加选项
                </el-button>
              </el-form-item>
              <el-form-item
                v-show="dialogAttributeForm.attributes[for_index].newLimitForm.inputType==='数字'"
                label="数字类型"
                :label-width="formLabelWidth"
              >
                <el-select v-model="dialogAttributeForm.attributes[for_index].newLimitForm.valueType" placeholder="请选择">
                  <el-option label="整数" value="整数" />
                  <el-option label="小数" value="小数" />
                </el-select>
              </el-form-item>
              <el-form-item
                v-show="dialogAttributeForm.attributes[for_index].newLimitForm.inputType==='数字'"
                label="数字小于"
                :label-width="formLabelWidth"
              >
                <el-input v-model="dialogAttributeForm.attributes[for_index].newLimitForm.valueLow" />
              </el-form-item>
              <el-form-item
                v-show="dialogAttributeForm.attributes[for_index].newLimitForm.inputType==='数字'"
                label="数字等于"
                :label-width="formLabelWidth"
              >
                <el-input v-model="dialogAttributeForm.attributes[for_index].newLimitForm.valueEqual" />
              </el-form-item>
              <el-form-item
                v-show="dialogAttributeForm.attributes[for_index].newLimitForm.inputType==='数字'"
                label="数字大于"
                :label-width="formLabelWidth"
              >
                <el-input v-model="dialogAttributeForm.attributes[for_index].newLimitForm.valueHigh" />
              </el-form-item>
              <el-form-item
                v-show="dialogAttributeForm.attributes[for_index].newLimitForm.inputType==='数字'&&dialogAttributeForm.attributes[for_index].newLimitForm.valueType==='小数'"
                label="小数的位数"
                :label-width="formLabelWidth"
              >
                <el-input v-model="dialogAttributeForm.attributes[for_index].newLimitForm.floatLength" />
              </el-form-item>
              <el-form-item
                v-show="dialogAttributeForm.attributes[for_index].newLimitForm.inputType==='数字'"
                label="数字长度小于"
                :label-width="formLabelWidth"
              >
                <el-input v-model="dialogAttributeForm.attributes[for_index].newLimitForm.lengthLow" />
              </el-form-item>
              <el-form-item
                v-show="dialogAttributeForm.attributes[for_index].newLimitForm.inputType==='数字'"
                label="数字长度等于"
                :label-width="formLabelWidth"
              >
                <el-input v-model="dialogAttributeForm.attributes[for_index].newLimitForm.lengthEqual" />
              </el-form-item>
              <el-form-item
                v-show="dialogAttributeForm.attributes[for_index].newLimitForm.inputType==='数字'"
                label="数字长度大于"
                :label-width="formLabelWidth"
              >
                <el-input v-model="dialogAttributeForm.attributes[for_index].newLimitForm.lengthHigh" />
              </el-form-item>
              <el-form-item
                v-show="dialogAttributeForm.attributes[for_index].newLimitForm.inputType==='纯文本'"
                label="字符串长度小于"
                :label-width="formLabelWidth"
              >
                <el-input v-model="dialogAttributeForm.attributes[for_index].newLimitForm.stringLengthLow" />
              </el-form-item>
              <el-form-item
                v-show="dialogAttributeForm.attributes[for_index].newLimitForm.inputType==='纯文本'"
                label="字符串长度等于"
                :label-width="formLabelWidth"
              >
                <el-input v-model="dialogAttributeForm.attributes[for_index].newLimitForm.stringLengthEqual" />
              </el-form-item>
              <el-form-item
                v-show="dialogAttributeForm.attributes[for_index].newLimitForm.inputType==='纯文本'"
                label="字符串长度大于"
                :label-width="formLabelWidth"
              >
                <el-input v-model="dialogAttributeForm.attributes[for_index].newLimitForm.stringLengthHigh" />
              </el-form-item>
            </el-form>
          </el-row>
          <div v-if="dialogAttributeForm.type === 'view'" style="color: black; margin-left: 40px">
            <br>
            <el-row>
              <el-table
                ref="table"
                :key="tableKey"
                :data="item.limitations"
                border
                fit
                style="width: 100%;"
              >
                <!-- lavObject -->
                <el-table-column
                  prop="lavObject"
                  label="lavObject"
                  align="center"
                />
                <!-- lavOperation -->
                <el-table-column
                  prop="lavOperation"
                  label="lavOperation"
                  align="center"
                />
                <!-- lavValue -->
                <el-table-column
                  prop="lavValue"
                  label="lavValue"
                  align="center"
                />
                <!-- 操作 -->
                <el-table-column
                  :label="$t('table.operation')"
                  align="center"
                  min-width="50px"
                  class-name="small-padding fixed-width"
                >
                  <template slot-scope="{row}">
                    <i
                      class="el-icon-setting table-operation"
                      style="color: #2db7f5;"
                      @click="handleAttributeLimitUpdate(row, dialogAttributeForm.attributes[for_index].limitations)"
                    />
                    <i
                      class="el-icon-delete table-operation"
                      style="color: #f50;"
                      @click="handleAttributeLimitDelete(row)"
                    />
                  </template>
                </el-table-column>
              </el-table>
            </el-row>
            <!-- <el-row
              v-for="i in item.limitations"
              :key="dialogAttributeForm.attributes[index].lavObject"
              style="width: 100%;"
            >
              <el-col :span="8"><span> {{ i.lavObject }} </span></el-col>
              <el-col :span="8"><span> {{ i.lavOperation }} </span></el-col>
              <el-col :span="8"><span> {{ i.lavValue }} </span></el-col>
            </el-row> -->
          </div>
        </div>
      </div>
      <span slot="footer" class="dialog-footer">
        <el-button
          v-if="dialogAttributeForm.type === 'insert'"
          type="primary"
          @click="insertAttributeLimit"
        >确 定</el-button>
        <el-button
          v-if="dialogAttributeForm.type !== 'insert'"
          type="primary"
          @click="dialogAttributeForm.Visible = false"
        >确 定</el-button>
        <el-button @click="dialogAttributeForm.Visible = false">取 消</el-button>
      </span>
    </el-dialog>
    <el-table
      ref="table"
      :key="tableKey"
      v-loading="loading"
      :data="list"
      height="700"
      border
      fit
      style="width: 100%;"
    >
      //序号
      <el-table-column
        label="序号"
        type="index"
        width="60px"
        align="center"
        style="padding-bottom: 20px;"
      >
        <template scope="scope">
          <span>{{ (pagination.num - 1) * pagination.size + scope.$index + 1 }}</span>
        </template>
      </el-table-column>
      //成果类型
      <el-table-column
        align="center"
        prop="asPositiveAward"
        label="成果类型"
        :filters="as_positive_award_type"
        :filter-method="filterTag5"
        width="120px"
      >
        <template slot-scope="scope">
          <el-tag
            :type="(scope.row.asPositiveAward)? 'success': 'danger'"
            disable-transitions
          >
            {{ scope.row.asPositiveAward ? '加分项' : '减分项' }}
          </el-tag>
        </template>
      </el-table-column>
      //评价方面
      <el-table-column
        prop="allScoringAspectValue"
        label="评价方面"
        align="center"
        width="120px"
        :filters="as_scoring_aspect"
        :filter-method="filterTag3"
        filter-placement="bottom-end"
      />
      //评分单项
      <el-table-column
        prop="allScoringItemValue"
        label="评分单项"
        align="center"
        width="150px"
        :filters="as_scoring_item"
        :filter-method="filterTag1"
        filter-placement="bottom-end"
      />
      //评分单项中的小项
      <el-table-column
        prop="allScoringLevelValue"
        label="评分小项"
        align="center"
        width="250px"
        :filters="as_award_level"
        :filter-method="filterTag2"
        filter-placement="bottom-end"
      />
      //评价方面权重
      <el-table-column
        align="center"
        prop="asAspectWeight"
        label="评价方面权重"
        sortable
        width="130px"
      />
      //评分单项权重
      <el-table-column
        align="center"
        prop="asItemWeight"
        label="评分单项权重"
        sortable
        width="130px"
      />
      //该小项的权重
      <el-table-column
        align="center"
        prop="asWeight"
        label="该小项的权重"
        sortable
        width="130px"
      />
      //该小项的分值
      <el-table-column
        align="center"
        prop="asValue"
        label="该小项的分值"
        sortable
        width="130px"
      />
      //激活状态
      <el-table-column
        prop="asState"
        label="激活状态"
        width="100px"
        align="center"
        :filters="as_state_type"
        :filter-method="filterTag4"
        filter-placement="bottom-end"
      >
        <template slot-scope="scope">
          <el-tag
            :type="(scope.row.asState)? 'success': 'info'"
            disable-transitions
          >
            {{ scope.row.asState ? '激活' : '未激活' }}
          </el-tag>
        </template>
      </el-table-column>
      //更新时间
      <el-table-column
        align="center"
        prop="asDateTime"
        label="更新时间"
        sortable
        width="150px"
        column-key="date"
      />
      //操作
      <el-table-column
        :label="$t('table.operation')"
        align="center"
        min-width="150px"
        class-name="small-padding fixed-width"
      >
        <template slot-scope="{row}">
          <i class="el-icon-view table-operation" style="color: #87d068;" @click="handleView(row)" />
          <i class="el-icon-setting table-operation" style="color: #2db7f5;" @click="handleUpdate(row)" />
          <i class="el-icon-delete table-operation" style="color: #f50;" @click="handleDelete(row)" />
        </template>
      </el-table-column>
    </el-table>
    <pagination
      v-show="total>0"
      :total="total"
      :page.sync="pagination.num"
      :limit.sync="pagination.size"
      @pagination="fetchTable"
    />
  </div>
</template>

<script>
import axios from 'axios'
import { getToken } from '@/utils/auth'
import Pagination from '@/components/Pagination'

export default {
  components: { Pagination },
  data() {
    return {
      deleteLimits: '',
      dialogVisible: false,
      dialogFormVisible: false,
      dialogAttributeForm: {
        changeAttributeTypeVisible: false,
        addAttributeLimitVisible: false,
        loading: true,
        Visible: false,
        asIndex: '',
        insertAttributeVisible: false,
        insertAttributeForm: {
          attributeNames: [],
          asIndex: ''
        },
        deleteAttributeVisible: false,
        deleteAttributeForm: '',
        type: 'view', // insert view
        insertAttributeLimitVisible: false,
        deleteAttributeLimitVisible: false,
        updateAttributeLimitVisible: false,
        addChoicesVisible: false,
        selectedAttributes: {
          aaIndex: '', // 成果属性
          asIndex: '', // 成果类型
          aaAttribute: '',
          aaState: '',
          aaAttributeIndex: '',
          aaEditTime: '',
          aavlIndex: '', // 成果属性限制
          newLimitForm: {
            inputType: '', // 输入框-类型
            inputTypeIs: false,
            multiSelectWidth: '', // 多选-选择范围
            multiSelectWidthIs: false,
            singleSelectWidth: '', // 单选-选择范围
            singleSelectWidthIs: false,
            floatLength: '', // 小数-位数
            floatLengthIs: false,
            lengthLow: '', // 数字长度-小于
            lengthLowIs: false,
            lengthEqual: '', // 数字长度-等于
            lengthEqualIs: false,
            lengthHigh: '', // 数字长度-大于
            lengthHighIs: false,
            valueLow: '', // 数字-小于
            valueLowIs: false,
            valueEqual: '', // 数字-等于
            valueEqualIs: false,
            valueHigh: '', // 数字-大于
            valueHighIs: false,
            valueType: '', // 数字-类型
            valueTypeIs: false,
            stringLengthLow: '', // 字符串长度-小于
            stringLengthLowIs: false,
            stringLengthEqual: '', // 字符串长度-等于
            stringLengthEqualIs: false,
            stringLengthHigh: '', // 字符串长度-大于
            stringLengthHighIs: false
          }
        },
        addChoiceForm: {
          aaIndex: '',
          choiceType: '',
          choices: [],
          fatherName: ''
        },
        selectedLimit: {
          aavlIndex: '',
          aaIndex: '',
          lavObject: '',
          lavOperation: '',
          lavValue: '',
          aaAttributeIndex: ''
        },
        attributes: [{
          aaIndex: '', // 成果属性
          asIndex: '', // 成果类型
          aaAttribute: '',
          aaState: '',
          aaAttributeIndex: '',
          aaEditTime: '',
          aavlIndex: '', // 成果属性限制
          newLimitForm: {
            inputType: '', // 输入框-类型
            multiSelectWidth: '', // 多选-选择范围
            singleSelectWidth: '', // 单选-选择范围
            floatLength: '', // 小数-位数
            lengthLow: '', // 数字长度-小于
            lengthEqual: '', // 数字长度-等于
            lengthHigh: '', // 数字长度-大于
            valueLow: '', // 数字-小于
            valueEqual: '', // 数字-等于
            valueHigh: '', // 数字-大于
            valueType: '', // 数字-类型
            stringLengthLow: '', // 字符串长度-小于
            stringLengthEqual: '', // 字符串长度-等于
            stringLengthHigh: '' // 字符串长度-大于
          },
          limitations: [{
            aavlIndex: '',
            aaIndex: '',
            lavObject: '',
            lavOperation: '',
            lavValue: '',
            aaAttributeIndex: ''
          }]
        }
        ]
      },
      form: {
        title: '具体信息',
        as_positive_award: '加分项',
        as_scoring_item: '',
        as_award_level: '',
        as_scoring_aspect: '',
        attributes: [],
        as_state: true,
        up_type: null,
        as_aspect_weight: 50,
        as_item_weight: 50,
        as_level_value: 50,
        as_level_weight: 50,
        is_normalized: true,
        attributesOptions: [{
          value: '成果名称',
          label: '成果名称'
        }, {
          value: '成果获得时间',
          label: '成果获得时间'
        }]
      },
      selects: null,
      formLabelWidth: '200px',
      as_scoring_item: [],
      as_scoring_aspect: [],
      as_award_level: [],
      as_positive_award_type: [
        {
          text: '加分項',
          value: true
        },
        {
          text: '減分項',
          value: false
        }
      ],
      as_state_type: [
        {
          text: '激活',
          value: true
        },
        {
          text: '未激活',
          value: false
        }
      ],
      list: [],
      loading: false,
      tableKey: 0,
      total: 0,
      pagination: {
        num: 1,
        size: 10
      }
    }
  },
  computed: {
    currentUser() {
      return this.$store.state.account.user
    }
  },
  mounted() {
    this.fetchType()
    this.fetchTable()
  },
  methods: {
    fetchTable() {
      this.loading = true
      this.list = []
      this.$get('achievement/award/queryAllAwardKind', {
        pageNum: this.pagination.num,
        showPerPage: this.pagination.size
      }).then((r) => {
        const data = r.data.data
        this.total = data.countAll
        for (let i = 0; i < data.awardStructures.length; i++) {
          this.list.push(
            {
              asIndex: data.awardStructures[i].asIndex,
              asPositiveAward: data.awardStructures[i].asPositiveAward,
              asScoringItem: data.awardStructures[i].asScoringItem,
              asAwardLevel: data.awardStructures[i].asAwardLevel,
              asScoringAspect: data.awardStructures[i].asScoringAspect,
              asWeight: data.awardStructures[i].asLevelWeight,
              asValue: data.awardStructures[i].asLevelValue,
              asState: data.awardStructures[i].asState,
              asEditTime: data.awardStructures[i].asEditTime,
              asAspectWeight: data.awardStructures[i].asAspectWeight,
              asItemWeight: data.awardStructures[i].asItemWeight,
              asItemIfNormalized: data.awardStructures[i].asItemIfNormalized,
              asDateTime: (typeof data.awardStructures[i].asEditTime === 'undefined') ? 'NULL' : data.awardStructures[i].asEditTime.slice(0, 10) + '  ' + data.awardStructures[i].asEditTime.slice(11, 19),
              allScoringLevelValue: data.allScoringLevelValue[i],
              allScoringItemValue: data.allScoringItemValue[i],
              allScoringAspectValue: data.allScoringAspectValue[i]
            }
          )
        }
        this.loading = false
      })
    },
    fetchType() {
      this.$get('achievement/award/queryAwardAttr', {
        colName: 'as_award_level'
      }).then((r) => {
        const Type = r.data.data
        this.as_award_level = []
        for (let i = 0; i < Type.stateItemsId.length; i++) {
          this.as_award_level.push(
            {
              value: Type.stateItemsValue[i],
              text: Type.stateItemsValue[i],
              colIndex: Type.stateItemsId[i]
            }
          )
        }
        // console.log(this.as_award_level);
      })

      this.$get('achievement/award/queryAwardAttr', {
        colName: 'as_scoring_item'
      }).then((r) => {
        const Type = r.data.data
        this.as_scoring_item = []
        for (let i = 0; i < Type.stateItemsValue.length; i++) {
          this.as_scoring_item.push(
            {
              value: Type.stateItemsValue[i],
              text: Type.stateItemsValue[i],
              colIndex: Type.stateItemsId[i]
            }
          )
        }
        // console.log(this.as_scoring_item);
      })

      this.$get('achievement/award/queryAwardAttr', {
        colName: 'as_scoring_aspect'
      }).then((r) => {
        const Type = r.data.data
        this.as_scoring_aspect = []
        // console.log(Type.colName.length);
        for (let i = 0; i < Type.stateItemsValue.length; i++) {
          this.as_scoring_aspect.push(
            {
              value: Type.stateItemsValue[i],
              text: Type.stateItemsValue[i],
              colIndex: Type.stateItemsId[i]
            }
          )
        }
        // console.log(this.as_scoring_aspect);
      })
    },
    fetchAttribute() {
      this.dialogAttributeForm.loading = true
      this.dialogAttributeForm.Visible = true
      this.$get('achievement/award/getAwardAttributeCorrespondToAwardStructure', {
        asIndex: this.dialogAttributeForm.asIndex
      }).then((r) => {
        const data = r.data.data
        // console.log(data);
        for (let i = 0; i < data.length; i++) {
          data[i]['newLimitForm'] = {
            inputType: '', // 输入框-类型
            multiSelectWidth: '', // 多选-选择范围
            singleSelectWidth: '', // 单选-选择范围
            floatLength: '', // 小数-位数
            lengthLow: '', // 数字长度-小于
            lengthEqual: '', // 数字长度-等于
            lengthHigh: '', // 数字长度-大于
            valueLow: '', // 数字-小于
            valueEqual: '', // 数字-等于
            valueHigh: '', // 数字-大于
            valueType: '', // 数字-类型
            stringLengthLow: '', // 字符串长度-小于
            stringLengthEqual: '', // 字符串长度-等于
            stringLengthHigh: '' // 字符串长度-大于
          }
        }
        this.dialogAttributeForm.attributes = data
        // console.log(this.dialogAttributeForm.attributes)
        this.dialogAttributeForm.loading = false
        if (this.dialogAttributeForm.type === 'view') {
          this.fetchAttributeLimitations()
        }
      })
    },
    fetchAttributeLimitations() {
      this.dialogAttributeForm.loading = true
      for (let i = 0; i < this.dialogAttributeForm.attributes.length; i++) {
        this.dialogAttributeForm.attributes[i].limitations = []
      }
      this.$get('achievement/award/getAwardAttributeLimitationCorrespondToAwardStructure', {
        asIndex: this.dialogAttributeForm.asIndex
      }).then((r) => {
        const data = r.data.data
        // console.log(data)
        for (const key in data) {
          if (data[key].length !== 0) {
            const currentIndex = this.dialogAttributeForm.attributes.findIndex((element) => element.aaIndex === data[key][0].aaIndex)
            this.dialogAttributeForm.attributes[currentIndex].limitations = data[key]
          }
        }
        // console.log(this.dialogAttributeForm.attributes)
        this.dialogAttributeForm.loading = false
      })
    },
    handleAttributeInsert() {
      this.dialogAttributeForm.insertAttributeForm.asIndex = this.dialogAttributeForm.asIndex
      this.dialogAttributeForm.insertAttributeForm.attributeNames = []
      this.dialogAttributeForm.insertAttributeVisible = true
    },
    insertAttribute() {
      axios({
        method: 'post',
        url: '/api/achievement/award/addAttribute',
        headers: {
          'Authorization': 'bearer ' + getToken(),
          'Content-Type': 'application/json;charset=UTF-8'
        },
        data: JSON.stringify({
          asIndex: this.dialogAttributeForm.insertAttributeForm.asIndex,
          attributeNames: this.dialogAttributeForm.insertAttributeForm.attributeNames
        })
      }).then((response) => {
        // console.log(response)
        this.fetchAttribute()
        this.dialogAttributeForm.insertAttributeVisible = false
      })
    },
    handleAttributeDelete(item) {
      this.dialogAttributeForm.deleteAttributeForm = item
      this.dialogAttributeForm.deleteAttributeVisible = true
    },
    deleteAttribute() {
      this.$delete('achievement/award/deleteAttribute?aaIndex=' + this.dialogAttributeForm.deleteAttributeForm.aaIndex).then((response) => {
        // console.log(response)
        this.fetchAttribute()
        this.dialogAttributeForm.deleteAttributeVisible = false
      })
    },
    handleAddChoicesInInsert(item) {
      this.dialogAttributeForm.addChoiceForm.aaIndex = item.aaIndex
      this.dialogAttributeForm.addChoiceForm.choiceType = item.newLimitForm.inputType
      this.dialogAttributeForm.addChoiceForm.choices = []
      this.dialogAttributeForm.addChoiceForm.fatherName = (item.newLimitForm.inputType === '单选') ? item.newLimitForm.multiSelectWidth : item.newLimitForm.singleSelectWidth
      this.dialogAttributeForm.addChoicesVisible = true
    },
    addChoices() {
      axios({
        method: 'post',
        url: '/api/achievement/award/addChoices',
        headers: {
          'Authorization': 'bearer ' + getToken(),
          'Content-Type': 'application/json;charset=UTF-8'
        },
        data: JSON.stringify(this.dialogAttributeForm.addChoiceForm)
      }).then((response) => {
        // console.log(response)
        this.dialogAttributeForm.addChoicesVisible = false
      })
    },
    handleAttributeLimitUpdate(row, index_data) {
      console.log(index_data)
      this.deleteLimits = index_data
      // this.dialogAttributeForm.selectedLimit = row
      this.dialogAttributeForm.selectedLimit.aaAttributeIndex = row.aaAttributeIndex
      this.dialogAttributeForm.selectedLimit.aaIndex = row.aaIndex
      this.dialogAttributeForm.selectedLimit.aavlIndex = row.aavlIndex
      this.dialogAttributeForm.selectedLimit.lavObject = row.lavObject
      this.dialogAttributeForm.selectedLimit.lavOperation = row.lavOperation
      this.dialogAttributeForm.selectedLimit.lavValue = row.lavValue
      this.dialogAttributeForm.updateAttributeLimitVisible = true
    },
    handleAddChoicesInChange() {
      this.dialogAttributeForm.addChoiceForm.aaIndex = this.dialogAttributeForm.selectedLimit.aaIndex
      this.dialogAttributeForm.addChoiceForm.choiceType = this.dialogAttributeForm.selectedLimit.lavObject
      this.dialogAttributeForm.addChoiceForm.choices = []
      this.dialogAttributeForm.addChoiceForm.fatherName = this.dialogAttributeForm.selectedLimit.lavValue
      this.dialogAttributeForm.addChoicesVisible = true
    },
    handleAttributeLimitInsert(index) {
      this.dialogAttributeForm.selectedAttributes = this.dialogAttributeForm.attributes[index]
      this.dialogAttributeForm.selectedAttributes['newLimitForm'] =
        {
          inputType: '', // 输入框-类型
          inputTypeIs: false,
          multiSelectWidth: '', // 多选-选择范围
          multiSelectWidthIs: false,
          singleSelectWidth: '', // 单选-选择范围
          singleSelectWidthIs: false,
          floatLength: '', // 小数-位数
          floatLengthIs: false,
          lengthLow: '', // 数字长度-小于
          lengthLowIs: false,
          lengthEqual: '', // 数字长度-等于
          lengthEqualIs: false,
          lengthHigh: '', // 数字长度-大于
          lengthHighIs: false,
          valueLow: '', // 数字-小于
          valueLowIs: false,
          valueEqual: '', // 数字-等于
          valueEqualIs: false,
          valueHigh: '', // 数字-大于
          valueHighIs: false,
          valueType: '', // 数字-类型
          valueTypeIs: false,
          stringLengthLow: '', // 字符串长度-小于
          stringLengthLowIs: false,
          stringLengthEqual: '', // 字符串长度-等于
          stringLengthEqualIs: false,
          stringLengthHigh: '', // 字符串长度-大于
          stringLengthHighIs: false
        }
      for (let i = 0; i < this.dialogAttributeForm.selectedAttributes.limitations.length; i++) {
        const data = this.dialogAttributeForm.selectedAttributes.limitations[i]
        if (data.lavObject === '输入框' && data.lavOperation === '类型') {
          this.dialogAttributeForm.selectedAttributes.newLimitForm.inputType = data.lavValue
          this.dialogAttributeForm.selectedAttributes.newLimitForm.inputTypeIs = true
        }
        if (data.lavObject === '多选' && data.lavOperation === '选择范围') {
          this.dialogAttributeForm.selectedAttributes.newLimitForm.multiSelectWidth = data.lavValue
          this.dialogAttributeForm.selectedAttributes.newLimitForm.multiSelectWidthIs = true
        }
        if (data.lavObject === '单选' && data.lavOperation === '选择范围') {
          this.dialogAttributeForm.selectedAttributes.newLimitForm.singleSelectWidth = data.lavValue
          this.dialogAttributeForm.selectedAttributes.newLimitForm.singleSelectWidthIs = true
        }
        if (data.lavObject === '小数' && data.lavOperation === '位数') {
          this.dialogAttributeForm.selectedAttributes.newLimitForm.floatLength = data.lavValue
          this.dialogAttributeForm.selectedAttributes.newLimitForm.floatLengthIs = true
        }
        if (data.lavObject === '数字长度' && data.lavOperation === '小于') {
          this.dialogAttributeForm.selectedAttributes.newLimitForm.lengthLow = data.lavValue
          this.dialogAttributeForm.selectedAttributes.newLimitForm.lengthLowIs = true
        }
        if (data.lavObject === '数字长度' && data.lavOperation === '等于') {
          this.dialogAttributeForm.selectedAttributes.newLimitForm.lengthEqual = data.lavValue
          this.dialogAttributeForm.selectedAttributes.newLimitForm.lengthEqualIs = true
        }
        if (data.lavObject === '数字长度' && data.lavOperation === '大于') {
          this.dialogAttributeForm.selectedAttributes.newLimitForm.lengthHigh = data.lavValue
          this.dialogAttributeForm.selectedAttributes.newLimitForm.lengthHighIs = true
        }
        if (data.lavObject === '数字' && data.lavOperation === '小于') {
          this.dialogAttributeForm.selectedAttributes.newLimitForm.valueLow = data.lavValue
          this.dialogAttributeForm.selectedAttributes.newLimitForm.valueLowIs = true
        }
        if (data.lavObject === '数字' && data.lavOperation === '等于') {
          this.dialogAttributeForm.selectedAttributes.newLimitForm.valueEqual = data.lavValue
          this.dialogAttributeForm.selectedAttributes.newLimitForm.valueEqualIs = true
        }
        if (data.lavObject === '数字' && data.lavOperation === '大于') {
          this.dialogAttributeForm.selectedAttributes.newLimitForm.valueHigh = data.lavValue
          this.dialogAttributeForm.selectedAttributes.newLimitForm.valueHighIs = true
        }
        if (data.lavObject === '字符串长度' && data.lavOperation === '小于') {
          this.dialogAttributeForm.selectedAttributes.newLimitForm.stringLengthLow = data.lavValue
          this.dialogAttributeForm.selectedAttributes.newLimitForm.stringLengthLowIs = true
        }
        if (data.lavObject === '字符串长度' && data.lavOperation === '等于') {
          this.dialogAttributeForm.selectedAttributes.newLimitForm.stringLengthEqual = data.lavValue
          this.dialogAttributeForm.selectedAttributes.newLimitForm.stringLengthEqualIs = true
        }
        if (data.lavObject === '字符串长度' && data.lavOperation === '大于') {
          this.dialogAttributeForm.selectedAttributes.newLimitForm.stringLengthHigh = data.lavValue
          this.dialogAttributeForm.selectedAttributes.newLimitForm.stringLengthHighIs = true
        }
        if (data.lavObject === '数字' && data.lavOperation === '类型') {
          this.dialogAttributeForm.selectedAttributes.newLimitForm.valueType = data.lavValue
          this.dialogAttributeForm.selectedAttributes.newLimitForm.valueTypeIs = true
        }
      }
      console.log(this.dialogAttributeForm.selectedAttributes)
      this.dialogAttributeForm.addAttributeLimitVisible = true
      // console.log(item)
    },
    handleAttributeLimitDelete(row) {
      // console.log(row)
      this.dialogAttributeForm.selectedLimit = row
      this.dialogAttributeForm.deleteAttributeLimitVisible = true
    },
    updateAttributeLimit() {
      axios({
        method: 'post',
        url: '/api/achievement/award/updateAttributeLimitation',
        headers: {
          'Authorization': 'bearer ' + getToken(),
          'Content-Type':
            'application/json;charset=UTF-8'
        },
        data: JSON.stringify(this.dialogAttributeForm.selectedLimit)
      }).then((response) => {
        // console.log(response)
        this.fetchAttribute()
        this.dialogAttributeForm.updateAttributeLimitVisible = false
      })
    },
    changeAttributeType() {
      for (let i = 0; i < this.deleteLimits.length; i++) {
        if (this.deleteLimits[i].lavOperation !== '类型') {
          axios({
            method: 'delete',
            url: '/api/achievement/award/deleteAttributeLimitation',
            headers: {
              'Authorization': 'bearer ' + getToken(),
              'Content-Type': 'application/json;charset=UTF-8'
            },
            params: {
              aavlIndex: this.deleteLimits[i].aavlIndex
            },
            data: JSON.stringify(this.deleteLimits[i])
          })
        }
      }
      axios({
        method: 'post',
        url: '/api/achievement/award/updateAttributeLimitations',
        headers: {
          'Authorization': 'bearer ' + getToken(),
          'Content-Type': 'application/json;charset=UTF-8'
        },
        data: JSON.stringify([this.dialogAttributeForm.selectedLimit])
      }).then((response) => {
        // console.log(response)
        this.fetchAttribute()
        this.dialogAttributeForm.changeAttributeTypeVisible = false
        this.dialogAttributeForm.updateAttributeLimitVisible = false
      })
    },
    deleteAttributeLimit() {
      axios({
        method: 'delete',
        url: '/api/achievement/award/deleteAttributeLimitation',
        headers: {
          'Authorization': 'bearer ' + getToken(),
          'Content-Type': 'application/json;charset=UTF-8'
        },
        params: {
          aavlIndex: this.dialogAttributeForm.selectedLimit.aavlIndex
        },
        data: JSON.stringify(this.dialogAttributeForm.selectedLimit)
      }).then((response) => {
        // console.log(response)
        this.fetchAttribute()
        this.dialogAttributeForm.deleteAttributeLimitVisible = false
      })
    },
    updateAttributeLimits() {
      const params = []
      const selectData = this.dialogAttributeForm.selectedAttributes
      if (selectData.newLimitForm.inputType && selectData.newLimitForm.inputTypeIs === false) {
        params.push({
          aaAttributeIndex: selectData.aaAttributeIndex,
          aaIndex: selectData.aaIndex,
          aavlIndex: 0,
          lavObject: '输入框',
          lavOperation: '类型',
          lavValue: selectData.newLimitForm.inputType
        })
      }
      if (selectData.newLimitForm.inputType === '单选') {
        if (selectData.newLimitForm.singleSelectWidth && selectData.newLimitForm.singleSelectWidthIs === false) {
          params.push({
            aaAttributeIndex: selectData.aaAttributeIndex,
            aaIndex: selectData.aaIndex,
            aavlIndex: 0,
            lavObject: '单选',
            lavOperation: '选择范围',
            lavValue: selectData.newLimitForm.singleSelectWidth
          })
        }
      }
      if (selectData.newLimitForm.inputType === '多选') {
        if (selectData.newLimitForm.multiSelectWidth && selectData.newLimitForm.multiSelectWidthIs === false) {
          params.push({
            aaAttributeIndex: selectData.aaAttributeIndex,
            aaIndex: selectData.aaIndex,
            aavlIndex: 0,
            lavObject: '多选',
            lavOperation: '选择范围',
            lavValue: selectData.newLimitForm.multiSelectWidth
          })
        }
      }
      if (selectData.newLimitForm.inputType === '数字') {
        if (selectData.newLimitForm.valueType && selectData.newLimitForm.valueTypeIs === false) {
          params.push({
            aaAttributeIndex: selectData.aaAttributeIndex,
            aaIndex: selectData.aaIndex,
            aavlIndex: 0,
            lavObject: '数字',
            lavOperation: '类型',
            lavValue: selectData.newLimitForm.valueType
          })
        }
        if (selectData.newLimitForm.valueLow && selectData.newLimitForm.valueLowIs === false) {
          params.push({
            aaAttributeIndex: selectData.aaAttributeIndex,
            aaIndex: selectData.aaIndex,
            aavlIndex: 0,
            lavObject: '数字',
            lavOperation: '小于',
            lavValue: selectData.newLimitForm.valueLow
          })
        }
        if (selectData.newLimitForm.valueEqual && selectData.newLimitForm.valueEqualIs === false) {
          params.push({
            aaAttributeIndex: selectData.aaAttributeIndex,
            aaIndex: selectData.aaIndex,
            aavlIndex: 0,
            lavObject: '数字',
            lavOperation: '等于',
            lavValue: selectData.newLimitForm.valueEqual
          })
        }
        if (selectData.newLimitForm.valueHigh && selectData.newLimitForm.valueHighIs === false) {
          params.push({
            aaAttributeIndex: selectData.aaAttributeIndex,
            aaIndex: selectData.aaIndex,
            aavlIndex: 0,
            lavObject: '数字',
            lavOperation: '大于',
            lavValue: selectData.newLimitForm.valueHigh
          })
        }
        if (selectData.newLimitForm.lengthLow && selectData.newLimitForm.lengthLowIs === false) {
          params.push({
            aaAttributeIndex: selectData.aaAttributeIndex,
            aaIndex: selectData.aaIndex,
            aavlIndex: 0,
            lavObject: '数字长度',
            lavOperation: '小于',
            lavValue: selectData.newLimitForm.lengthLow
          })
        }
        if (selectData.newLimitForm.lengthEqual && selectData.newLimitForm.lengthEqualIs === false) {
          params.push({
            aaAttributeIndex: selectData.aaAttributeIndex,
            aaIndex: selectData.aaIndex,
            aavlIndex: 0,
            lavObject: '数字长度',
            lavOperation: '等于',
            lavValue: selectData.newLimitForm.lengthEqual
          })
        }
        if (selectData.newLimitForm.lengthHigh && selectData.newLimitForm.lengthHighIs === false) {
          params.push({
            aaAttributeIndex: selectData.aaAttributeIndex,
            aaIndex: selectData.aaIndex,
            aavlIndex: 0,
            lavObject: '数字长度',
            lavOperation: '大于',
            lavValue: selectData.newLimitForm.lengthHigh
          })
        }
        if (selectData.newLimitForm.valueType === '小数') {
          if (selectData.newLimitForm.floatLength && selectData.newLimitForm.floatLengthIs === false) {
            params.push({
              aaAttributeIndex: selectData.aaAttributeIndex,
              aaIndex: selectData.aaIndex,
              aavlIndex: 0,
              lavObject: '小数',
              lavOperation: '位数',
              lavValue: selectData.newLimitForm.floatLength
            })
          }
        }
      }
      if (selectData.newLimitForm.inputType === '纯文本') {
        if (selectData.newLimitForm.stringLengthLow && selectData.newLimitForm.stringLengthLowIs === false) {
          params.push({
            aaAttributeIndex: selectData.aaAttributeIndex,
            aaIndex: selectData.aaIndex,
            aavlIndex: 0,
            lavObject: '字符串长度',
            lavOperation: '小于',
            lavValue: selectData.newLimitForm.stringLengthLow
          })
        }
        if (selectData.newLimitForm.stringLengthEqual && selectData.newLimitForm.stringLengthEqualIs === false) {
          params.push({
            aaAttributeIndex: selectData.aaAttributeIndex,
            aaIndex: selectData.aaIndex,
            aavlIndex: 0,
            lavObject: '字符串长度',
            lavOperation: '等于',
            lavValue: selectData.newLimitForm.stringLengthEqual
          })
        }
        if (selectData.newLimitForm.stringLengthHigh && selectData.newLimitForm.stringLengthHighIs === false) {
          params.push({
            aaAttributeIndex: selectData.aaAttributeIndex,
            aaIndex: selectData.aaIndex,
            aavlIndex: 0,
            lavObject: '字符串长度',
            lavOperation: '大于',
            lavValue: selectData.newLimitForm.stringLengthHigh
          })
        }
      }
      axios({
        method: 'post',
        url: '/api/achievement/award/addAttributeLimitation',
        headers: {
          'Authorization': 'bearer ' + getToken(),
          'Content-Type': 'application/json;charset=UTF-8'
        },
        data: JSON.stringify(params)
      }).then((response) => {
        // console.log(response)
        this.dialogAttributeForm.addAttributeLimitVisible = false
        this.fetchAttribute()
      })
    },
    insertAttributeLimit() {
      const params = []
      for (let i = 0; i < this.dialogAttributeForm.attributes.length; i++) {
        const selectData = this.dialogAttributeForm.attributes[i]
        if (selectData.newLimitForm.inputType) {
          params.push({
            aaAttributeIndex: selectData.aaAttributeIndex,
            aaIndex: selectData.aaIndex,
            aavlIndex: 0,
            lavObject: '输入框',
            lavOperation: '类型',
            lavValue: selectData.newLimitForm.inputType
          })
        }
        if (selectData.newLimitForm.inputType === '单选') {
          if (selectData.newLimitForm.singleSelectWidth) {
            params.push({
              aaAttributeIndex: selectData.aaAttributeIndex,
              aaIndex: selectData.aaIndex,
              aavlIndex: 0,
              lavObject: '单选',
              lavOperation: '选择范围',
              lavValue: selectData.newLimitForm.singleSelectWidth
            })
          }
        }
        if (selectData.newLimitForm.inputType === '多选') {
          if (selectData.newLimitForm.multiSelectWidth) {
            params.push({
              aaAttributeIndex: selectData.aaAttributeIndex,
              aaIndex: selectData.aaIndex,
              aavlIndex: 0,
              lavObject: '多选',
              lavOperation: '选择范围',
              lavValue: selectData.newLimitForm.multiSelectWidth
            })
          }
        }
        if (selectData.newLimitForm.inputType === '数字') {
          if (selectData.newLimitForm.valueType) {
            params.push({
              aaAttributeIndex: selectData.aaAttributeIndex,
              aaIndex: selectData.aaIndex,
              aavlIndex: 0,
              lavObject: '数字',
              lavOperation: '类型',
              lavValue: selectData.newLimitForm.valueType
            })
          }
          if (selectData.newLimitForm.valueLow) {
            params.push({
              aaAttributeIndex: selectData.aaAttributeIndex,
              aaIndex: selectData.aaIndex,
              aavlIndex: 0,
              lavObject: '数字',
              lavOperation: '小于',
              lavValue: selectData.newLimitForm.valueLow
            })
          }
          if (selectData.newLimitForm.valueEqual) {
            params.push({
              aaAttributeIndex: selectData.aaAttributeIndex,
              aaIndex: selectData.aaIndex,
              aavlIndex: 0,
              lavObject: '数字',
              lavOperation: '等于',
              lavValue: selectData.newLimitForm.valueEqual
            })
          }
          if (selectData.newLimitForm.valueHigh) {
            params.push({
              aaAttributeIndex: selectData.aaAttributeIndex,
              aaIndex: selectData.aaIndex,
              aavlIndex: 0,
              lavObject: '数字',
              lavOperation: '大于',
              lavValue: selectData.newLimitForm.valueHigh
            })
          }
          if (selectData.newLimitForm.lengthLow) {
            params.push({
              aaAttributeIndex: selectData.aaAttributeIndex,
              aaIndex: selectData.aaIndex,
              aavlIndex: 0,
              lavObject: '数字长度',
              lavOperation: '小于',
              lavValue: selectData.newLimitForm.lengthLow
            })
          }
          if (selectData.newLimitForm.lengthEqual) {
            params.push({
              aaAttributeIndex: selectData.aaAttributeIndex,
              aaIndex: selectData.aaIndex,
              aavlIndex: 0,
              lavObject: '数字长度',
              lavOperation: '等于',
              lavValue: selectData.newLimitForm.lengthEqual
            })
          }
          if (selectData.newLimitForm.lengthHigh) {
            params.push({
              aaAttributeIndex: selectData.aaAttributeIndex,
              aaIndex: selectData.aaIndex,
              aavlIndex: 0,
              lavObject: '数字长度',
              lavOperation: '大于',
              lavValue: selectData.newLimitForm.lengthHigh
            })
          }
          if (selectData.newLimitForm.valueType === '小数') {
            if (selectData.newLimitForm.floatLength) {
              params.push({
                aaAttributeIndex: selectData.aaAttributeIndex,
                aaIndex: selectData.aaIndex,
                aavlIndex: 0,
                lavObject: '小数',
                lavOperation: '位数',
                lavValue: selectData.newLimitForm.floatLength
              })
            }
          }
        }
        if (selectData.newLimitForm.inputType === '纯文本') {
          if (selectData.newLimitForm.stringLengthLow) {
            params.push({
              aaAttributeIndex: selectData.aaAttributeIndex,
              aaIndex: selectData.aaIndex,
              aavlIndex: 0,
              lavObject: '字符串长度',
              lavOperation: '小于',
              lavValue: selectData.newLimitForm.stringLengthLow
            })
          }
          if (selectData.newLimitForm.stringLengthEqual) {
            params.push({
              aaAttributeIndex: selectData.aaAttributeIndex,
              aaIndex: selectData.aaIndex,
              aavlIndex: 0,
              lavObject: '字符串长度',
              lavOperation: '等于',
              lavValue: selectData.newLimitForm.stringLengthEqual
            })
          }
          if (selectData.newLimitForm.stringLengthHigh) {
            params.push({
              aaAttributeIndex: selectData.aaAttributeIndex,
              aaIndex: selectData.aaIndex,
              aavlIndex: 0,
              lavObject: '字符串长度',
              lavOperation: '大于',
              lavValue: selectData.newLimitForm.stringLengthHigh
            })
          }
        }
      }
      axios({
        method: 'post',
        url: '/api/achievement/award/addAttributeLimitation',
        headers: {
          'Authorization': 'bearer ' + getToken(),
          'Content-Type': 'application/json;charset=UTF-8'
        },
        data: JSON.stringify(params)
      }).then((response) => {
        // console.log(response)
        this.fetchTable()
        this.dialogAttributeForm.Visible = false
      })
    },
    filterTag1(value, row) {
      return row.allScoringItemValue === value
    },
    filterTag2(value, row) {
      return row.allScoringLevelValue === value
    },
    filterTag3(value, row) {
      return row.allScoringAspectValue === value
    },
    filterTag4(value, row) {
      return row.asState === value
    },
    filterTag5(value, row) {
      return row.asPositiveAward === value
    },
    handleFormClick() {
      if (this.form.up_type === 'Insert') {
        this.awardInsert()
      } else if (this.form.up_type === 'Update') {
        this.awardUpdate()
      } else {
        this.dialogFormVisible = false
      }
    },
    handleDelete(row) {
      this.selects = row
      this.dialogVisible = true
    },
    handleInsert() {
      this.form.title = '新增成果类型'
      this.form.up_type = 'Insert'
      this.form.as_positive_award = '加分项'
      this.form.as_scoring_item = ''
      this.form.as_award_level = ''
      this.form.as_scoring_aspect = ''
      this.form.as_weight = 50
      this.form.as_value = 50
      this.form.attributes = []
      this.form.as_state = true
      this.dialogFormVisible = true
    },
    handleView(row) {
      // console.log(row)
      this.dialogAttributeForm.type = 'view'
      this.dialogAttributeForm.asIndex = row.asIndex
      this.fetchAttribute()
    },
    handleUpdate(row) {
      this.selects = row
      this.form.title = '修改成果类型'
      this.form.up_type = 'Update'
      this.form.as_positive_award = row.asPositiveAward ? '加分项' : '减分项'
      this.form.as_scoring_item = this.as_scoring_item.find((element) => element.colIndex === row.asScoringItem).text
      this.form.as_award_level = this.as_award_level.find((element) => element.colIndex === row.asAwardLevel).text
      this.form.as_scoring_aspect = this.as_scoring_aspect.find((element) => element.colIndex === row.asScoringAspect).text
      this.form.attributes = []
      this.form.as_state = row.asState
      this.form.is_normalized = row.asItemIfNormalized
      this.form.as_aspect_weight = row.asAspectWeight
      this.form.as_item_weight = row.asItemWeight
      this.form.as_level_value = row.asValue
      this.form.as_level_weight = row.asWeight
      this.dialogFormVisible = true
    },
    awardInsert() {
      axios({
        method: 'post',
        url: '/api/achievement/award/insertAwardKind',
        headers: {
          'Authorization': 'bearer ' + getToken(),
          'Content-Type': 'application/json;charset=UTF-8'
        },
        data: JSON.stringify({
          as_positive_award: (this.form.as_positive_award === '加分项') ? '加分项' : '减分项', // 配合后端接口
          as_scoring_item: this.form.as_scoring_item,
          as_award_level: this.form.as_award_level,
          as_scoring_aspect: this.form.as_scoring_aspect,
          attributes: this.form.attributes,
          as_aspect_weight: this.form.as_aspect_weight,
          as_item_weight: this.form.as_item_weight,
          as_level_value: this.form.as_level_value,
          as_level_weight: this.form.as_level_weight,
          is_normalized: true
        })
      }).then((response) => {
        // console.log(response)
        this.dialogFormVisible = false
        this.fetchTable()
        this.dialogAttributeForm.type = 'insert'
        this.dialogAttributeForm.asIndex = response.data.data
        this.fetchAttribute()
      }).catch(function(error) {
        // console.log(error.response.data);
        console.log(error.response.status)
        // console.log(error.response.headers);
      })
    },
    awardUpdate() {
      axios({
        method: 'post',
        url: '/api/achievement/award/updateAwardKind',
        headers: {
          'Authorization': 'bearer ' + getToken(),
          'Content-Type': 'application/json;charset=UTF-8'
        },
        data:
          JSON.stringify({
            as_index: this.selects.asIndex,
            as_positive_award: this.form.as_positive_award,
            as_scoring_aspect: this.form.as_scoring_aspect,
            as_scoring_item: this.form.as_scoring_item,
            as_award_level: this.form.as_award_level,
            as_aspect_weight: this.form.as_aspect_weight,
            as_item_weight: this.form.as_item_weight,
            as_level_value: this.form.as_level_value,
            as_level_weight: this.form.as_level_weight,
            is_normalized: this.form.is_normalized,
            as_state: this.form.as_state
          })
      }).then((response) => {
        // console.log(response)
        if (response.data.status === 'fail') {
          // console.log(response.data)
          this.$message({
            message: response.data.errInfo,
            type: 'warning'
          })
        }
        this.dialogFormVisible = false
        this.fetchTable()
      }).catch((error) => {
        // console.log(error.response.data);
        console.log(error.response.status)
        // console.log(error.response.headers);
      })
    },
    awardDelete() {
      this.$delete('achievement/award/deleteAwardKind?asIndex=' + this.selects.asIndex).then((response) => {
        // console.log(response)
        if (response.data.status === 'fail') {
          // console.log(response.data)
          this.$message({
            message: response.data.errInfo,
            type: 'warning'
          })
        }
        this.fetchTable()
        this.dialogVisible = false
      })
    },
    handleClose(done) {
      this.$confirm('确认关闭？')
        .then(_ => {
          done()
        })
        .catch(_ => {
        })
    },
    querySearchScoringAspect(queryString, cb) {
      const scoringItem = this.as_scoring_aspect
      const results = queryString ? scoringItem.filter(this.createFilter(queryString)) : scoringItem
      // 调用 callback 返回建议列表的数据
      cb(results)
    },
    querySearchScoringItem(queryString, cb) {
      const scoringItem = this.as_scoring_item
      const results = queryString ? scoringItem.filter(this.createFilter(queryString)) : scoringItem
      // 调用 callback 返回建议列表的数据
      cb(results)
    },
    querySearchAwardLevel(queryString, cb) {
      const scoringItem = this.as_award_level
      const results = queryString ? scoringItem.filter(this.createFilter(queryString)) : scoringItem
      // 调用 callback 返回建议列表的数据
      cb(results)
    },
    createFilter(queryString) {
      return (scoringItem) => {
        return (scoringItem.value.toLowerCase().indexOf(queryString.toLowerCase()) === 0)
      }
    },
    handleSelect(item) {
      // console.log(item);
    }
  }
}
</script>
<style lang="scss" scoped>
.AttributeItem {
  align-items: center;
  justify-content: center;
  padding: 20px;
  background: #e8f3fe;
  margin: 10px;
  color: #7dbcfc;
}
</style>
